﻿using UnityEngine;
using System.Collections;
using Dict.DataModel;
using ProtoBuf.Message;

namespace Room
{
    public class RCUIUnionFightMonster : RCUIPlayer
    {
        public TableUnionFightNpc dictData;

        float arriveDis;
        
        
        public RCUIUnionFightMonster(RoomCharactor owner)
            : base(owner)
        {
            this.owner = owner;
            type = UIType.UnionMonster;
            ClickRange = (float)Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.UnionFightCanClickMonsterRange;
            arriveDis = (float)Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.UnionFightArriveMonster;
        }

        public void Init(TableUnionFightNpc dictData)
        {
            this.dictData = dictData;
        }

        public void ClickEvent()
        {
            OnClick();
        }

        protected override void OnClick()
        {
            var self = owner.charactorManager.GetSelfCharactor();
            if(self!=null)
            {
                var ai = self.ai as RCAIUnionSelf;
                if(ai!=null && ai.IdleState() )
                {
                    ai.AutoGoto(owner.transform.position, () => { }, arriveDis);
                }
            }
        }
    }
}
